package com.shanjupay.merchant.service.impl;

import com.shanjupay.common.domain.BusinessException;
import com.shanjupay.common.domain.CommonErrorCode;
import com.shanjupay.common.util.QiniuUtils;
import com.shanjupay.merchant.service.FileService;

/**
 * @program: shanjupay
 * @description: 上传文件实现类
 * @author: Mr.Hkc
 * @create: 2020-08-18 23:22
 **/
public class FileServiceImpl implements FileService {
    /**
     * 上传文件
     * @param bytes 文件字节数组
     * @param filename 文件名
     * @return
     * @throws BusinessException
     */
    @Override
    public String upload(byte[] bytes, String filename) throws BusinessException {
        String Qiniu_url = "http://qe7kmmeec.bkt.clouddn.com/";
        try {
            //调用common工具类
            QiniuUtils.upload2Qiniu(bytes,filename);
        } catch (Exception e) {
            e.printStackTrace();
            throw new BusinessException(CommonErrorCode.E_100106);
        }
        return Qiniu_url + filename;
    }
}

